package com.nhim.cms.admin.server.locator;

import com.google.gwt.requestfactory.shared.Locator;
import com.nhim.cms.dao.ElementTemplateDAO;
import com.nhim.cms.dao.IElementTemplateDAO;
import com.nhim.cms.domain.ElementTemplate;
import com.nhim.cms.util.AppContext;

public class ElementTemplateLocator extends Locator<ElementTemplate, Integer> {
	IElementTemplateDAO ETDAO = ElementTemplateDAO
			.getFromApplicationContext(AppContext.getApplicationContext());

	@Override
	public ElementTemplate create(Class<? extends ElementTemplate> clazz) {
		return new ElementTemplate();
	}

	@Override
	public ElementTemplate find(Class<? extends ElementTemplate> clazz,
			Integer id) {
		if (id == null)
			return new ElementTemplate();
		return ETDAO.findById(id);
	}

	@Override
	public Class<ElementTemplate> getDomainType() {
		return ElementTemplate.class;
	}

	@Override
	public Integer getId(ElementTemplate domainObject) {
		return domainObject.getId();
	}

	@Override
	public Class<Integer> getIdType() {
		return Integer.class;
	}

	@Override
	public Object getVersion(ElementTemplate domainObject) {
		return domainObject.getVersion();
	}

	

}
